from apscheduler.schedulers.blocking import BlockingScheduler
from alarm import alarm_job
from constant import constant
from accident import accident_job
from health_index import health_job
from runtime import runtime_job






if __name__ == '__main__':
    try:
        scheduler = BlockingScheduler()
        scheduler.add_job(alarm_job, 'interval', seconds=10)
        scheduler.add_job(runtime_job, 'interval', seconds=5)
        scheduler.add_job(accident_job, 'interval', seconds=5)
        scheduler.add_job(health_job, 'interval', seconds=300)
        # scheduler.add_job(increment_electric_job, 'interval', seconds=1)
        # scheduler.add_job(insert_elec_increment, 'interval', minutes=5)
        # scheduler.add_job(increment_water_job, 'interval', seconds=1)
        # scheduler.add_job(insert_water_increment, 'interval', minutes=1)
        # scheduler.add_job(ZT().zt_01_02, 'interval', seconds=1)
        scheduler.start()
    except Exception as err:
        constant.logger.error(err)
        print(err)
        scheduler = BlockingScheduler()
        scheduler.add_job(alarm_job, 'interval', seconds=10)
        scheduler.add_job(runtime_job, 'interval', seconds=5)
        scheduler.add_job(accident_job, 'interval', seconds=5)
        scheduler.add_job(health_job, 'interval', seconds=300)
        scheduler.start()